﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MinhTuan;

public partial class admin_order_members : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String[] admin = Session["Admin"].ToString().Split(',');
        if (int.Parse(admin[0]) < 0)
        {
            Response.Redirect("http://localhost:2011/didong/admin/login.aspx");
        }
        if (!Page.IsPostBack)
        {
            show();
        }
    }
    protected void show()
    {
        this.products.DataSource = Members.GetMember();
        this.products.DataBind();
    }
    protected void products_ItemDeleting(object sender, ListViewDeleteEventArgs e)
    {
        ListViewItem item = products.Items[e.ItemIndex];
        if (item != null)
        {
            String Item = ((HiddenField)item.FindControl("hdid")).Value.ToString();
            int result;
            result = Members.DeleteMember(Convert.ToInt16(int.Parse(Item)));
            if (result<0)
            {
                this.Lbmessage.Text = "Xoá không thành công";
            }
            else
            {
                this.Lbmessage.Text = "Xoá thành công";
                show();

            }

        }
    }
    protected void products_ItemUpdating(object sender, ListViewUpdateEventArgs e)
    {

    }
    protected void products_PagePropertiesChanged(object sender, PagePropertiesChangingEventArgs e)
    {

    }
    protected void btn_Click(object sender, EventArgs e)
    {
        Int16 result = Members.DeleteMembernotOrder();
        if (result > 0)
        {
            show();
            Lbmessage.Text = "Có " + result + "Thành viên đuợc xoá";

        }
        else
        {
            Lbmessage.Text = "Không có thành viên nào đựơc xoá.";
        }

    }
}
